<?php
/*
 * Cookie类
 * @author andery <andery@foxmail.com>
 * @link http://www.Nimo.com/
 * @version $Id: CCookie.lib.php 2010-07-23 14:27:10Z andery $
 */
class CCookie{
	/**
	 * 获取COOKIE值
	 * @param string $name
	 */
	public static function get($name)
	{
	    if (isset($_COOKIE[CConf::get('cookie.cookiepre').$name])) {
	        return $_COOKIE[CConf::get('cookie.cookiepre').$name];
	    } else {
	        return false;
	    }
	}
	
	/**
	 * 设置COOKIE值
	 */
    public static function set($name, $value, $expire = '', $path = '', $domain = '', $prefix = '')
    {
        $prefix == '' && $prefix = CConf::get('cookie.cookiepre');
        $path == '' && $path= CConf::get('cookie.cookiepath');
        $domain == '' && $domain= CConf::get('cookie.cookiedomain');
        $expire = !empty($expire)? time()+$expire : 0;
        setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
    }
    
    /**
     * 删除指定COOKIE
     */
    public static function del($name = '', $path = '', $domain = '', $prefix = '')
    {
        self::set($name, '', '', $path, $domain, $prefix);
    }
    
    /**
     * 清除COOKIE
     */
    public static function clear()
    {
        unset($_COOKIE);
    }
}